﻿using System.Linq;
using UnityEngine;

public class CameraCtrl : MonoBehaviour, IControl<CameraCtrl> {
	// === Unity ======================================================================================================
	public void Update() {
		if (!SettingsGameModel.IsCamera2D) {
			return;
		}
		if (_screenSize.x.Equals(Screen.width) && _screenSize.y.Equals(Screen.height)) {
			return;
		}
		_screenSize = new Vector2(Screen.width, Screen.height);
		Managers.Camera.UpdateCameraSize();
	}

	// === Public =====================================================================================================
	#region IControl
	public CameraCtrl GetControl() {
		return this;
	}

	public void Initialize() {
		_screenSize = new Vector2(Screen.width, Screen.height);
	}

	public void Destroy() {
		Destroy(gameObject);
	}
	#endregion

	// === Private ====================================================================================================
	private Vector2 _screenSize;
}
